package com.hc.testaudio.deletea.ui

import android.Manifest
import android.os.Bundle
import com.hc.testaudio.deletea.util.AudioRecordUtil
import com.hc.testaudio.deletea.util.MediaPlayerUtil
import com.yc.yclibx.permissions.YcUtilPermission
import kotlinx.android.synthetic.main.media_recorder_activity.*


/**
 *
 */
class MediaRecorderTestActivity : BaseActivity() {
    var mMediaRecorderUtil = MediaPlayerUtil()
    override fun getLayoutId(): Int {
        return com.hc.testaudio.R.layout.media_recorder_activity
    }

    override fun initView(savedInstanceState: Bundle?) {
        YcUtilPermission.newInstance(activity).addPermissions(YcUtilPermission.PERMISSION_STORAGE)
                .addPermissions(Manifest.permission.RECORD_AUDIO)
                .addPermissions(Manifest.permission.CAMERA).start()
        startBtn.setOnClickListener {
            mMediaRecorderUtil.play()
        }
        endBtn.setOnClickListener {
            val mAudioRecordUtil = AudioRecordUtil()
            mAudioRecordUtil.start()
            //            Observable.interval(0, 200, TimeUnit.MILLISECONDS).observeOn(Schedulers.newThread())
            //                    .subscribe {
            //                        val mAudioManager = activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager
            //                        val volume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) //得到听筒模式的当前值
            //                        YcLog.e("音量：$volume")
            //                    }
            //            mMediaRecorderUtil.end()
        }
    }
}